//
//  ViewController.m
//  03.15-AppSettingsDemo
//
//  Created by student on 16/3/16.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self updateInfo];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(updateInfo) name:UIApplicationWillEnterForegroundNotification object:nil];
}
-(void)dealloc
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}

-(void)updateInfo
{
    NSUserDefaults *d=[NSUserDefaults standardUserDefaults];
    
    self.usernameLabel.text=[d objectForKey:@"username"];
    self.passwordLabel.text=[d valueForKey:@"password"];
    self.protocolusernameLabel.text=[d valueForKey:@"protocol"];
    
    self.wrapLabel.text=[d boolForKey:@"wrap"]?@"开":@"关";
    self.wrapSpeedLabel.text=[NSString stringWithFormat:@"%f",[d floatForKey:@"wrapSpeed"]];
    self.favoriteTeaLabel.text=[d valueForKey:@"favoriteTea"];
     self.favoriteCandyLabel.text=[d valueForKey:@"favoriteCandy"];
     self.favoriteGameLabel.text=[d valueForKey:@"favoriteGame"];
     self.favoriteExcuseLabel.text=[d valueForKey:@"favoriteExcuse"];
    self.favoriteSinLabel.text=[d valueForKey:@"favoriteSin"];
}

@end
